﻿using System;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using DeepZoomPivotConstructor.DTBuilderLib;
using DeepZoomSLUtilities.HotSpots.Specific;
using System.Collections.Generic;

namespace DeepZoomSLUtilities.HotSpots
{
    /// <summary>
    /// Class that is responsible for creating the HS objects given the link name
    /// </summary>
    public class HotSpotInfoFactory
    {
        /// <summary>
        /// Create a single hot spot action
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        public static HotSpotActionBase CreateHSAction (HotSpotInfo parent, DZHotSpotMetaData.ActionData info)
        {
            if (info.LinkType == "uri")
            {
                return new HSUri(parent, info);
            }
            else if (info.LinkType == "center")
            {
                return new HSCenter(parent, info);
            }
            else
            {
                ///
                /// Default: do nothing!
                /// 

                return null;
            }
        }

        /// <summary>
        /// Given a list of actions, create a list of HSActions. Mostly helper function - the real stuff is above.
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        internal static List<HotSpotActionBase> CreateHSActions(HotSpotInfo parent, List<DZHotSpotMetaData.ActionData> alist)
        {
            var actions = from a in alist
                          let hsa = CreateHSAction(parent, a)
                          where hsa != null
                          select hsa;

            return new List<HotSpotActionBase>(actions);
        }
    }
}
